home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Technology Demos and Tools.iso / showmetv / ShowMeTV / bin / showmetv
Encoding:
Text File  |  1996-02-27  |  5.4 KB  |  281 lines

  1. #!/bin/sh
  2. #
  3. # ShowMe TV startup script.
  4. #
  5. # @(#)showmetv.sh    1.11 96/02/26 Copyright 1993-96 Sun Microsystems, Inc.  All Rights Reserved.
  6. #
  7.  
  8.  
  9. #
  10. # Where various components of this application live.
  11. #
  12. ShowMeHome=
  13. showmeHome=
  14. utilsHome=
  15. helpHome=
  16. motifHome=
  17.  
  18. helpExecDir=
  19. showmeExecDir=
  20. machDepExecDir=
  21.  
  22. osVersion=
  23.  
  24.  
  25. programName=$0
  26.  
  27.  
  28. #
  29. # If a path name is a symbolic link, resolve it.
  30. #
  31. GetRealPath()
  32. {
  33.     pathName="$1"
  34.     level=1
  35.  
  36.  
  37.     while [ -h "$pathName" ] ; do
  38.  
  39.         level=`/bin/expr $level + 1`
  40.         if [ $level -gt 10 ] ; then
  41.             echo "$pathName: too many levels of symbolic links"
  42.             break;
  43.         fi
  44.  
  45.         #
  46.         # First, make sure we have an absolute path name.
  47.         #
  48.         if IsRelativePath "$pathName" ; then
  49.             pathName=`/bin/pwd`/"$pathName"
  50.         fi
  51.  
  52.         #
  53.         # Then determine where the link points (via "ls -l")
  54.         #
  55.         dirName=`/bin/dirname $pathName`
  56.         link=`/bin/ls -l $pathName | sed -e 's,.* -> ,,g'`
  57.  
  58.         if IsRelativePath "$link" ; then
  59.             pathName="$dirName"/"$link"
  60.         else
  61.             pathName="$link"
  62.         fi
  63.     done
  64.  
  65.     echo "$pathName"
  66.  
  67.     return 0
  68. }
  69.  
  70.  
  71. #
  72. # Is this a relative path name (i.e., doesn't begin with "/")?
  73. #
  74. IsRelativePath()
  75. {
  76.     pathName="$1"
  77.  
  78.     if [ `echo "$pathName" | sed -e 's,^/.*,absolute,g'` = "absolute" ] ; then
  79.         return 1
  80.     else
  81.         return 0
  82.     fi
  83. }
  84.  
  85.  
  86. #
  87. # Determine what version of Solaris we're running
  88. #
  89. GetOSVersion()
  90. {
  91.            OS=`/bin/uname -r`
  92.  
  93.     case $OS in
  94.     4.*)    osVersion=SUNOS;;
  95.     5.*)    case `/bin/uname -p` in 
  96.         sparc)
  97.             osVersion=SVR4;;
  98.         *86)
  99.             osVersion=I386;;
  100.         esac;;
  101.     A.*)
  102.         osVersion=HPUX;;
  103.     esac
  104.  
  105. }
  106.  
  107.  
  108. #
  109. # Determine where ShowMe TV lives.
  110. # We assume that it's two levels up above the directory containing
  111. # this script.
  112. #
  113. GetPaths()
  114. {
  115.     tmpDir=`GetRealPath $programName`
  116.     tmpDir=`dirname $tmpDir`
  117.     ShowMeHome=`( cd $tmpDir/../.. && /bin/pwd )`
  118.  
  119.     showmeHome=$ShowMeHome/ShowMeTV
  120.     utilsHome=$ShowMeHome/utilities
  121.     helpHome=$ShowMeHome/help
  122. #    motifHome=$ShowMeHome/motif
  123.     motifHome=/usr/dt/lib
  124. }
  125.  
  126.  
  127. #
  128. # Set up ShowMe TV environment.
  129. #
  130. SetupEnvironment()
  131. {
  132.     helpExecDir=$helpHome/bin
  133.     HHPATH=$showmeHome/share ; export HHPATH
  134.  
  135.     showmeExecDir=$showmeHome/bin
  136.     machDepExecDir=$showmeExecDir/bin-$osVersion
  137.     utilsBinDir=$utilsHome/bin
  138.     utilsExecDir=$utilsHome/bin/bin-$osVersion
  139.     sunsolBinDir=`dirname $0`
  140.  
  141.  
  142.     #
  143.     # Add ShowMe TV and HyperHelp executable directories to shell search path
  144.     #
  145.     PATH=${showmeExecDir}:${machDepExecDir}:${utilsBinDir}:${utilsExecDir}:${helpExecDir}:${sunsolBinDir}:${PATH}
  146.  
  147.     export PATH
  148.  
  149.     #
  150.     # Use our own Motif key_bindings because the built-in ones
  151.     # in the Motif library don't handle all the Sun keys correctly.
  152.     # However, if XMBINDDIR is already set, leave it alone!
  153.     #
  154.  
  155.     if [ -d ${motifHome}/share/key_bindings ]; then
  156.         XMBINDDIR=${XMBINDDIR:=${motifHome}/share/key_bindings}
  157.         export XMBINDDIR
  158.     fi
  159.  
  160.     #
  161.     # Needed for demo license.
  162.     #
  163.     SUNSOL_HOME=${ShowMeHome} ; export SUNSOL_HOME
  164. }
  165.  
  166. #
  167. # Make sure system has SUNWmfrun installed
  168. #
  169. CheckMotifPath()
  170. {
  171.     [ -d $motifHome ] || {
  172.  
  173.       # OK, /usr/dt/lib isn't there, but maybe it is installed
  174.       # elsewhere and LD_LIBRARY_PATH is set. Run this ldd
  175.       # on the binary to see if libXm is really not found. 
  176.       ldd $machDepExecDir/`basename $0` | fgrep "libXm" | fgrep "not found" > /dev/null 2>&1
  177.  
  178.       # If the grep matched then we matched "libXm" and "not found"
  179.       if [ $? = 0 ]
  180.       then
  181.         echo "`basename $0`: $motifHome not found"
  182.         echo "\tPlease install the SUNWmfrun (Motif RunTime Kit) package."
  183.         echo "\tThis package is bundled with Solaris 2.4 and above. If you"
  184.         echo "\tare running Solaris 2.3 you should install the 2.4 package"
  185.         echo "\tthat is included on the ShowMe TV 1.1 installation media."
  186.         echo "\tExiting `basename $0`"
  187.         exit 1
  188.       fi
  189.     }
  190. }
  191.  
  192. #
  193. # Update loader search path as necessary.
  194. #
  195. SetLibraryPath()
  196. {
  197.     motifLibDir=$motifHome/lib-$osVersion
  198.  
  199.  
  200.     [ -d $motifLibDir ] || {
  201.         echo "Sorry, can't run `basename $0` - the Motif shared library is missing."
  202.         exit 1
  203.     }
  204.  
  205.     #
  206.     # Setup Motif environment variables for SUNOS
  207.     #
  208.     if [ $osVersion = "SUNOS" ] ; then
  209.         XLIBDIR=$motifLibDir
  210.         export XLIBDIR
  211.         XLIBI18N_PATH=$motifLibDir/X11
  212.         export XLIBI18N_PATH
  213.         XKEYSYMDB=$motifLibDir/X11/XKeysymDB
  214.         export XKEYSYMDB
  215.     fi
  216.  
  217.     # On 4.x systems, we are required to set LD_LIBRARY_PATH
  218.     # On 5.2 and 5.3 systems, we must set it to pick up the patched libXt
  219.  
  220.     #
  221.     # Prepend the ShowMe TV specific X and Motif library directory,
  222.     # followed by the regular Sun OpenWindow library directory.
  223.     #
  224.     openwinHome=${OPENWINHOME:-/usr/openwin}
  225.  
  226.     case $OS in
  227.         4.*)
  228.         LD_LIBRARY_PATH=${motifLibDir}:${openwinHome}/lib:${LD_LIBRARY_PATH};;
  229.         5.[23])
  230.         LD_LIBRARY_PATH=${motifLibDir}:${motifLibDir}/patched-libs,5.2:${openwinHome}/lib:${LD_LIBRARY_PATH};;
  231.         *)
  232.         LD_LIBRARY_PATH=${motifLibDir}:${openwinHome}/lib:${LD_LIBRARY_PATH};;
  233.     esac
  234.  
  235.     export LD_LIBRARY_PATH
  236. }
  237.  
  238.  
  239. ####################################################
  240.  
  241. GetOSVersion
  242.  
  243. GetPaths
  244.  
  245. SetupEnvironment
  246.  
  247. case `basename $0` in
  248.     splitmov | mergemov | catmov)
  249.         # Don't need motif
  250.         ;;
  251.     showmetv | showmetvt | showmetvd)
  252.         # Need motif. Make sure it is installed
  253.         CheckMotifPath
  254.  
  255. # Old stuff for SUNWsunsol/motif. May need later for 4.x support
  256. #        SetLibraryPath
  257. #
  258. #        # Cleanup Motif key bindings
  259. #        if [ -x ${motifHome}/lib-${osVersion}/bin/delbind_util ]; then
  260. #            ${motifHome}/lib-${osVersion}/bin/delbind_util $*
  261. #        fi
  262.         ;;
  263. esac
  264.  
  265. case `basename $0` in
  266.     showmetv)
  267.     echo "Starting ShowMe TV 1.1"
  268.     ;;
  269.     showmetvt)
  270.     echo "Starting ShowMe Transmitter 1.1"
  271.     ;;
  272.     splitmov)
  273.     ;;
  274.     showmetvd)
  275.     ;;
  276. esac
  277.  
  278. exec $machDepExecDir/`basename $0` $@
  279.  
  280. exit 0
  281.